import webapp2
from google.appengine.api import users

# We are using django's simplejson
# module to format JSON strings:
from django.utils import simplejson

class userLogin(webapp2.RequestHandler):

    def get(self):
        user = users.get_current_user()
        if user:
            logoutURL = ''
            userNickName = ''
            logoutURL +=  users.create_logout_url('/')
            userNickName += user.nickname()
            userID = user.user_id()
            userEmail = user.email()
            greeting = {'urlKind': 'logout','nickname': userNickName,'currUrl': logoutURL, 'userId': userID, 'email': userEmail }
        else:
            loginURL = ''
            loginURL += users.create_login_url('/')
            greeting = {'urlKind': 'login', 'currUrl': loginURL}
        
       
        
        jsonLogin = simplejson.dumps({
            'userLoginStr'  : greeting,
        })
        self.response.out.write(jsonLogin)